From: Julien Grall Date: Wed, 7 Dec 2016 12:33:52 +0000 (+0000) Subject: xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3227 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:///%22http:/www.example.com/cgi/%22https:/?a=commitdiff_plain;h=8c6feb177d1e17466aed2fda8784acb1f9d18d11;p=xen.git xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper The emulation of the co-processor register ICC_SGI1R is the same as the system register ICC_SGI1R_EL1. So move the emulation outside and use the newly introduced helper vreg_emulate_sysreg64 to abstract the access. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 139b3051c3..ed588ab0a3 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -31,6 +31,7 @@ #include #include #include +#include /* * PIDR2: Only bits[7:4] are not implementation defined. We are @@ -1300,9 +1301,21 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir) return vgic_to_sgi(v, sgir, sgi_mode, virq, &target); } +static bool vgic_v3_emulate_sgi1r(struct cpu_user_regs *regs, uint64_t *r, + bool read) +{ + /* WO */ + if ( !read ) + return vgic_v3_to_sgi(current, *r); + else + { + gdprintk(XENLOG_WARNING, "Reading SGI1R_EL1 - WO register\n"); + return false; + } +} + static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) { - struct vcpu *v = current; struct hsr_sysreg sysreg = hsr.sysreg; ASSERT (hsr.ec == HSR_EC_SYSREG); @@ -1315,14 +1328,8 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) switch ( hsr.bits & HSR_SYSREG_REGS_MASK ) { case HSR_SYSREG_ICC_SGI1R_EL1: - /* WO */ - if ( !sysreg.read ) - return vgic_v3_to_sgi(v, get_user_reg(regs, sysreg.reg)); - else - { - gprintk(XENLOG_WARNING, "Reading SGI1R_EL1 - WO register\n"); - return false; - } + return vreg_emulate_sysreg64(regs, hsr, vgic_v3_emulate_sgi1r); + default: return false; }